package com.taoye.thread;

public class Demo12 {
	public static void main(String[] args) throws InterruptedException {
		Demo12Thread t = new Demo12Thread();
		t.start();
		Thread.sleep(10);
		t.interrupt();
	}
}

class Demo12Thread extends Thread {
	@Override
	public void run() {
		for (int i = 0; i < Integer.MAX_VALUE; i++) {
			if (this.isInterrupted()) { 
				//线程被终止时抛出异常留给程序处理
				throw new RuntimeException("线程被终止啦");
			}
			System.out.println("当前i=" + i);
		}
		System.out.println("线程执行结束了");
	}
}